using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Net;
using Arcadium.Audio;
using Arcadium.GameEntities.Characters;

namespace Arcadium.GameEntities
{
    /// <summary>
    /// Holding all info about a player.
    /// </summary>
    class Player
    {
        #region Field

        private PlayerIndex playerIndex;
        private int score = 0;

        // TODO: Import custom settings here:
        

        #endregion

        #region Properties

        public bool IsLocal { get; private set; }

        public Character Character { get; private set; }

        #endregion

        #region Initialization

        public Player(Character character) : this(null, character) { }

        public Player(PlayerIndex? playerIndex, Character character)
        {
            if (IsLocal = playerIndex.HasValue)
                this.playerIndex = playerIndex.Value;
            Character = character;
        }

        #endregion

        #region Update

        public void Update(GameTime gameTime)
        {
            Character.Update(gameTime);
        }

        /// <summary>
        /// Only called for LocalNetworkPlayers ergo, the controllers are PlayerControllers
        /// </summary>
        /// <param name="input"></param>
        public void HandleInput(InputState input)
        {
            if (!IsLocal)
                throw new InvalidOperationException("Can't handle input for a non controlable player.");
            //(Character as PlayableCharacter).HandleInput(input, playerIndex);
            (Character as NewCharacter).UpdateLocal(input, playerIndex);
        }


        #endregion
    }
}
